/*
============================================================================
 Name        : sd_lock.h
 Author      : Jian
 Version     :
 Copyright   : GPL
 Description : sd_semp.h - header file
============================================================================
*/

#ifndef SD_LOCK_H
#define SD_LOCK_H

/* INCLUDES */
#include "dd_define.h"

__DD_BEGIN_DECLS

sd_semp* sd_create_sem(int initVal) ;

int sd_wait_sem(sd_semp* sem) ;

int sd_post_sem(sd_semp* sem) ;

void sd_destroy_sem(sd_semp* sem) ;

#define dd_wait_sem(l, r) do {int err = -1; dd_log_sem(l, __FILE__, __LINE__, 1); err = sd_wait_sem(l); __DD_ASSERT_DEFENSE(err >= 0, dd_log_error("wait sem error : %d", err); r;) ;} while(0) ;
#define dd_post_sem(l, r) do {int err = -1; dd_log_sem(l, __FILE__, __LINE__, 0); err = sd_post_sem(l); __DD_ASSERT_DEFENSE(err >= 0, dd_log_error("post sem error : %d", err); r;) ;} while(0) ;

sd_rlock* sd_create_rlock() ;

int sd_wait_rlock(sd_rlock* lock) ;

int sd_post_rlock(sd_rlock* lock) ;

void sd_destroy_rlock(sd_rlock* lock) ;

__DD_END_DECLS

#endif  /* SD_LOCK_H */

/* End of File */
